// config/dev.ts
import type { UserConfigExport } from "@tarojs/cli";

const config: UserConfigExport<'vite'> = {
  h5: {
    devServer: {
      proxy: {
        "/api/workflow": {
          target: "http://188.103.147.179:30181",
          changeOrigin: true,
          rewrite: (path) => {
            // 原始请求路径 (e.g., /api/workflow)
            const oldPath = path;

            // 我们期望的重写规则
            const newPath = path.replace(/^\/api\/workflow/, "/largemodel/api/v1/workflow/run");

            // --- 关键的调试日志 ---
            console.log("--- [Taro Proxy Debug] ---");
            console.log("Original Path:", oldPath);
            console.log("Rewritten Path:", newPath);
            console.log(`Final Target URL: ${"http://188.103.147.179:30181"}${newPath}`);
            console.log("--------------------------");
            // ---------------------

            return newPath;
          },
        },
      },
    },
  },
  mini: {},
};

export default config;